<template>
	<view class="mainpadding2">
		<view class="mainpadding_top ffffff radius" style="position: relative;" v-for="item in list.data" :key="item.id"
			@click="jumpurl('/pages_forum/luntanxq?id=',item)">
			<view class="lanlable" v-if="item.state==1">审核中</view>
			<view class="lvlable" v-if="item.state==2">已通过</view>
			<view class="honglable" v-if="item.state==3">不通过</view>
			<view class="flexleft">
				<image :src="item.user.avatar" mode="" class="listheadplimg"></image>
				<view class="flexcolumnbet" style="height: 70rpx;">
					<view class="xiaohei margin_left1">{{item.user.nickname}}</view>
					<view class="xiaohui margin_left1">{{item.createtime_text}}</view>
				</view>
			</view>
			<view class="pdl">
				<view class="hei_text bold main_size margin_top2 lianghang">{{item.title}}</view>
				<view class="xiaohui margin_top2 lianghang">{{item.description}}</view>
				<view class="flexleft">
					<view class="itemimgBox flexcenter margin_top" v-for="(ite,inde) in item.images_arr" :key="inde">
						<image class="listleftimg radius" :src="ite" mode=""></image>
					</view>
				</view>
			</view>
			<template v-if="item.state==2">
				<view class="margin_top flexbetween" style="padding: 0 60rpx;">
					<!-- <view class="flexleft" @click.stop="bianji(item.id)" v-if="item.status=='hidden'">
						<u-icon name="edit-pen" color="#333" size="16"></u-icon>
						<view class="xiaohei">编辑</view>
					</view> -->
					<view class="flexleft" @click.stop="updown(item)" v-if="item.status=='normal'">
						<u-icon name="arrow-down" color="#333" size="16"></u-icon>
						<view class="xiaohei">下架</view>
					</view>
					<view class="flexleft" @click.stop="updown(item)" v-if="item.status=='hidden'">
						<u-icon name="arrow-up" color="#333" size="16"></u-icon>
						<view class="xiaohei">上架</view>
					</view>
					<view class="flexleft" @click.stop="shanchu(item.id)">
						<u-icon name="trash" color="#333" size="16"></u-icon>
						<view class="xiaohei">删除</view>
					</view>
					<view class="flexleft">
						<u-icon name="chat" color="#333" size="16"></u-icon>
						<view class="xiaohei">评论</view>
					</view>
				</view>
			</template>
			<template v-else>
				<view class="flexcenter" style="padding: 0 60rpx;">
					<!-- <view class="flexcenter" v-if="item.state == 3" @click.stop="bianji(item.id)">
						<u-icon name="edit-pen" color="#333" size="16"></u-icon>
						<view class="xiaohei">重新发布</view>
					</view> -->
					<view class="flexcenter" @click.stop="shanchu(item.id)">
						<u-icon name="trash" color="#333" size="16"></u-icon>
						<view class="xiaohei">删除</view>
					</view>
				</view>
			</template>
			<view class="mainpadding_top bghong radius" v-if="item.state==3">
				<view class="xiaohong">原因：{{item.error_reason}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			shanchu(id) {
				httpRequest.modal('提示', '确定删除此论坛信息吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/community/del', 'POST', {
							id
						}).then(res => {
							httpRequest.toast(res.msg)
							this.init()
						})
					}
				})
			},
			jumpurl(url, item) {
				if(item.state==2 && item.status == "normal"){
					uni.navigateTo({
						url: url + item.id
					})
				}
			},
			updown(item) {
				httpRequest.request('/api/community/updown', 'POST', {
					id: item.id
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if (res.code == 1) {
						item.status = item.status == 'normal' ? 'hidden' : 'normal'
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			bianji(id) {
				uni.navigateTo({
					url: '/pages_forum/fabult?id=' + id
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/community/getmylist', 'GET', {
					page: page || 1,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>